Copied from upstream:
https://hg.mozilla.org/releases/mozilla-esr38/raw-rev/beae8783b8c2

# HG changeset patch
# User Paul Adenot <paul@paul.cx>
# Date 1456422965 0
# Node ID beae8783b8c2c672da12a95c70ae663cbd0d5016
# Parent  3a606f8182c82480f8f350b622ab55a170ec1eb6
Bug 1179484. r=roc

MozReview-Commit-ID: HNaYLyMe3sM

diff --git a/dom/media/webaudio/MediaStreamAudioDestinationNode.cpp b/dom/media/webaudio/MediaStreamAudioDestinationNode.cpp
--- a/dom/media/webaudio/MediaStreamAudioDestinationNode.cpp
+++ b/dom/media/webaudio/MediaStreamAudioDestinationNode.cpp
@@ -69,16 +69,20 @@ MediaStreamAudioDestinationNode::MediaSt
               ChannelInterpretation::Speakers)
   , mDOMStream(DOMAudioNodeMediaStream::CreateTrackUnionStream(GetOwner(),
                                                                this))
 {
   TrackUnionStream* tus = static_cast<TrackUnionStream*>(mDOMStream->GetStream());
   MOZ_ASSERT(tus == mDOMStream->GetStream()->AsProcessedStream());
   tus->SetTrackIDFilter(FilterAudioNodeStreamTrack);
 
+  if (aContext->Graph() != tus->Graph()) {
+    return;
+  }
+
   MediaStreamDestinationEngine* engine = new MediaStreamDestinationEngine(this, tus);
   mStream = aContext->Graph()->CreateAudioNodeStream(engine, MediaStreamGraph::INTERNAL_STREAM);
   mPort = tus->AllocateInputPort(mStream, 0);
 
   nsIDocument* doc = aContext->GetParentObject()->GetExtantDoc();
   if (doc) {
     mDOMStream->CombineWithPrincipal(doc->NodePrincipal());
   }

